@echo off
setlocal enabledelayedexpansion
title Enable Display HDR - Windows HDR Enabler
chcp 65001 > nul

rem =================================================================
rem Auto-elevate to Administrator if not already running as admin
rem =================================================================
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo [INFO] Requesting administrator privileges...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

rem =================================================================
rem Enable Display HDR (High Dynamic Range) - Complete Enable
rem =================================================================
echo [INFO] Completely enabling display HDR functionality...

rem Enable HDR through multiple registry paths and methods
powershell -Command "& { try { Write-Host '[INFO] Enabling HDR through registry settings...'; $regPaths = @('HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings', 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings', 'HKCU:\SOFTWARE\Microsoft\DirectX\UserGpuPreferences', 'HKLM:\SOFTWARE\Microsoft\DirectX\UserGpuPreferences'); foreach ($regPath in $regPaths) { try { if (!(Test-Path $regPath)) { New-Item -Path $regPath -Force | Out-Null }; Set-ItemProperty -Path $regPath -Name 'EnableAdvancedColorMode' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue; Set-ItemProperty -Path $regPath -Name 'EnableHDR' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue; Set-ItemProperty -Path $regPath -Name 'HDREnabled' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue; Write-Host '[SUCCESS] HDR enabled in' $regPath } catch { Write-Host '[WARNING] Could not modify' $regPath } }; Write-Host '[INFO] Enabling HDR for all display adapters...'; try { $adapters = Get-WmiObject -Class Win32_VideoController -ErrorAction SilentlyContinue; foreach ($adapter in $adapters) { if ($adapter.Name) { Write-Host '[INFO] Processing adapter:' $adapter.Name; $adapterKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}'; $subKeys = Get-ChildItem -Path $adapterKey -ErrorAction SilentlyContinue; foreach ($subKey in $subKeys) { try { Set-ItemProperty -Path $subKey.PSPath -Name 'EnableHDR' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue; Set-ItemProperty -Path $subKey.PSPath -Name 'HDRSupported' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue } catch {} } } } } catch { Write-Host '[WARNING] Could not process display adapters' }; Write-Host '[INFO] Enabling Windows HDR settings...'; try { $hdrPath = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced'; if (!(Test-Path $hdrPath)) { New-Item -Path $hdrPath -Force | Out-Null }; Set-ItemProperty -Path $hdrPath -Name 'EnableAutoHDR' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue; Set-ItemProperty -Path $hdrPath -Name 'AutoHDR' -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue } catch { Write-Host '[WARNING] Could not enable Windows HDR settings' }; Write-Host '[SUCCESS] HDR enable configuration completed' } catch { Write-Host '[WARNING] HDR configuration not available on this system' } }" 2>nul

rem Additional HDR enable through direct registry commands
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings" /v "EnableAdvancedColorMode" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings" /v "EnableHDR" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings" /v "HDREnabled" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings" /v "EnableAdvancedColorMode" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings" /v "EnableHDR" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\VideoSettings" /v "HDREnabled" /t REG_DWORD /d 1 /f >nul 2>&1

rem Enable Auto HDR for gaming (Windows 11)
reg add "HKCU\SOFTWARE\Microsoft\DirectX\UserGpuPreferences" /v "DirectXUserGlobalSettings" /t REG_SZ /d "SwapEffectUpgradeEnable=1;VRROptimizeEnable=1;AutoHDREnable=1;" /f >nul 2>&1
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "EnableAutoHDR" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "AutoHDR" /t REG_DWORD /d 1 /f >nul 2>&1

rem Enable HDR in display color settings
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" /v "EnableTransparency" /t REG_DWORD /d 1 /f >nul 2>&1
reg add "HKCU\Control Panel\Desktop" /v "AutoColorization" /t REG_DWORD /d 1 /f >nul 2>&1

if %errorlevel% equ 0 (
    echo [SUCCESS] Display HDR has been completely enabled.
    echo [INFO] HDR settings have been enabled system-wide.
) else (
    echo [WARNING] Some HDR settings may not have been changed.
)

echo.
echo =================================================================
echo [COMPLETE] HDR Enable Configuration Finished!
echo =================================================================
echo.
echo [INFO] HDR has been enabled for your display.
echo [INFO] You may need to restart your system for all changes to take effect.
echo [INFO] After restart, you can verify HDR is working in:
echo        - Windows Settings ^> System ^> Display ^> HDR
echo        - Graphics driver control panel
echo.

choice /c YN /n /m "Restart computer now to apply all changes? (Y/N): "
if !errorlevel!==1 (
    echo [INFO] Restarting computer in 10 seconds...
    echo [INFO] Press Ctrl+C to cancel restart.
    timeout /t 10
    shutdown /r /t 0
) else (
    echo [INFO] Please restart your computer manually when convenient.
    echo Press any key to exit...
    pause >nul
)